function convertForm2Json(formId){
    var jsonForm = [];
    var jsonRow = {};
    $(formId +" tr").each(function(){
//        var jsonRow = {};
//        jsonRow["language"] = $(this).children("td:first").text();
        $(this).children().each(function() {
            jsonRow[$(this).attr("name")] = $(this).text();
        });
//        jsonRow["fromIndex"] = $(this).children("td:nth-child(2)").text();
//        jsonRow["toIndex"] = $(this).children("td:nth-child(3)").text();
        jsonForm.push(jsonRow);
    });
//    alert("" + jsonForm.length);
//    return jsonForm;
    return 1 == jsonForm.length ? jsonForm[0] : jsonForm;
}

function showCart() {
    //define common cart-list url in header.jsp
    location = cartListURL;
}

function showOrders() {
    //define common orders-list url in footer.jsp
    location = orderListURL;
}

function toast(msgCode) {
    if("cartAddingDup" == msgCode) {
        
        $("#cartAddingToastDup").show(1000,function() {
            $(this).hide();
        });
    } else if("cartAddingFailure" == msgCode) {
        $("#cartAddingToastFailure").show(1000,function() {
            $(this).hide();
        });
    }
}